from fastapi.responses import JSONResponse
from typing import Any
from app.utils.response import BaseResponse


def resp_200(data: Any = None, message: str = "success") -> JSONResponse:
    """成功响应"""
    content = BaseResponse[Any](code=200, message=message, data=data).model_dump()
    return JSONResponse(status_code=200, content=content)


def resp_400(message: str = "Bad Request", data: Any = None) -> JSONResponse:
    """客户端错误响应"""
    content = BaseResponse[Any](code=400, message=message, data=data).model_dump()
    return JSONResponse(status_code=400, content=content)


def resp_500(message: str = "Internal Server Error") -> JSONResponse:
    """服务端错误响应"""
    content = BaseResponse[Any](code=500, message=message).model_dump()
    return JSONResponse(status_code=500, content=content)
